#!/usr/bin/env php
<?php

use Swoole\Event;

require dirname(__DIR__) . '/vendor/autoload.php';
ini_set('date.timezone', date_default_timezone_get());

$statusCode = 0;
go(function () use (&$statusCode) {
    go(function () use (&$statusCode) {
        try
        {
            if ($phpunitPath = getenv('TEST_PHPUNIT_PATH'))
            {
                require $phpunitPath;
            }
            PHPUnit\TextUI\Command::main(false);
        }
        catch (\Swoole\ExitException $e)
        {
            $statusCode = $e->getStatus();
        }
        Event::exit();
    });
});
Event::wait();
exit($statusCode);
